package whf.framework.config;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import whf.framework.log.Log;
import whf.framework.log.LogFactory;

/**
 * @author wanghaifeng
 *
 */
public final class XmlConfiguration extends BaseConfiguration {

	private static Log log = LogFactory.getLog(XmlConfiguration.class);
	
	public XmlConfiguration(String config) throws ConfigurationException{
		try{
			this.configuration = new org.apache.commons.configuration.XMLConfiguration(config);
		}catch(Exception e){
			log.error(this, e);
			throw new ConfigurationException(e);
		}
	}

	public XmlConfiguration(URL config) throws ConfigurationException{
		try{
			this.configuration = new org.apache.commons.configuration.XMLConfiguration(config);
		}catch(Exception e){
			log.error(this, e);
			throw new ConfigurationException(e);
		}
	}

	/* (non-Javadoc)
	 * @see whf.framework.config.IConfiguration#getIncList(java.lang.String)
	 */
	public List<String> getIncList(String key){
		List<String> list = new ArrayList<String>();
		for(int i=0;i<100;i++){
			String s = getString(key+"_"+i);
			if(s != null){
				list.add(s);
			}
		}
		return list;
	}
}
